package com.iking.housekeeping.service.user;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.iking.housekeeping.dao.user.SysUserMapper;
import com.iking.housekeeping.entity.user.SysUser;

/**
 * 用户管理Service
 * @author 秦甫杰
 *
 */
@Service
public class UserService {

	@Autowired
	private SysUserMapper sysUserMapper;

	/**
	 * 添加用户
	 * 
	 * @param sysUser
	 * @return
	 */
	public int addSysUser(SysUser sysUser) {
		return sysUserMapper.insertSelective(sysUser);
	}

	/**
	 * 删除用户
	 * 
	 * @param fId
	 * @return
	 */
	public int delUserById(@Param("fId") String fId) {
		return sysUserMapper.deleteByPrimaryKey(fId);
	}

	/**
	 * 更新用户
	 * 
	 * @param sysUser
	 * @return
	 */
	public int updateUserByID(SysUser sysUser) {
		return sysUserMapper.updateByPrimaryKeySelective(sysUser);
	}

	/**
	 * 根据id查询用户
	 * 
	 * @param fId
	 * @return
	 */
	public SysUser selectUserById(String fId) {
		return sysUserMapper.selectByPrimaryKey(fId);
	}

	/**
	 * 查询用户名是否存在
	 * 
	 * @param name
	 * @return
	 */
	public SysUser selectUserByName(String name) {
		return sysUserMapper.selectByLoginName(name);
	}
	
	/**
	 * 根据id查询用户
	 * @param userId
	 * @return
	 */
	public List<SysUser> selectSysUserByUserId(List<String> userId){
		return sysUserMapper.selectAllSysUserByFId(userId);
	}

	/**
	 * 根据用户ID列表多删用户
	 * @param userIdList
	 * @return
	 */
	public int delUserByIdList(List<String> userIdList) {
		return sysUserMapper.deleteByIdList(userIdList);
	}
}
